package lawyer.controller;

import common.model.Propaganda;
import lawyer.Service.PropagandaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/lawyer/propaganda")
public class PropagandaController {

    @Autowired
    private PropagandaService propagandaService;

    @PostMapping("/publish")
    public ResponseEntity<Void> publishPropaganda(@RequestBody Propaganda propaganda) {
        propagandaService.publishPropaganda(propaganda);
        return ResponseEntity.noContent().build();
    }

    @GetMapping("/manage")
    public ResponseEntity<List<Propaganda>> managePropaganda(@RequestParam(required = false) Boolean approved,
                                                             @RequestParam(required = false) String type,
                                                             @RequestParam(required = false) Date publishDate,
                                                             @RequestParam Long lawyerId) {
        return ResponseEntity.ok(propagandaService.managePropaganda(approved, type, publishDate, lawyerId));
    }
}
